<template>
  <div class="box">
    <div class="nav">
      <div>预警识别率</div>
      <div class="time">
        <div class="border-r" :class="handleDataType == 'day' ? 'timexz' : ''" @click="tabhandle('day')">当天</div>
        <div class="border-r" :class="handleDataType == 'month' ? 'timexz' : ''" @click="tabhandle('month')">当月</div>
        <div :class="handleDataType == 'year' ? 'timexz' : ''" @click="tabhandle('year')">当年</div>
      </div>
    </div>
    <div class="datashow">
      <div style="flex: 1">
        <img src="./imgs/yxl.png" />
        <div>有效率</div>
        <div>{{ datasum.yxl }}%</div>
      </div>
      <div style="flex: 1">
        <img src="./imgs/zql.png" />
        <div>准确率</div>
        <div>{{ datasum.wbl }}%</div>
      </div>
    </div>
  </div>
</template>

<script>
import useView from "@/hooks/useView";
import { defineComponent, reactive, toRefs } from "vue";
import baseService from "@/service/baseService";

export default defineComponent({
  name: "RealTimeTree",
  setup() {
    const state = reactive({
      handleDataType: "day",
      datasum: {}
    });
    return { ...useView(state), ...toRefs(state) };
  },
  created() {
    this.getInfo();
  },
  methods: {
    tabhandle(data) {
      this.handleDataType = data;
      this.getInfo();
    },
    // 获取信息
    getInfo() {
      let data = {
        type: this.handleDataType
      };
      baseService.get(`/statistics/kxstatistics/getHandleStatusNum`, data).then((res) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        }
        this.datasum = res.data;
      });
    }
  }
});
</script>

<style lang="scss" scoped>
.border-r {
  border-right: 1px rgba($color: #1e516a, $alpha: 0.7) solid;
}

.timexz {
  color: #022430;
  background-color: #12dbf2;
}
.box {
  color: #fff;
  width: 100%;
  padding: 0px;
  overflow: hidden;
  position: relative;
  flex: 1;

  .nav {
    height: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0px 10px;
    background-color: rgb(12, 90, 110);

    .time {
      cursor: pointer;
      color: #12dbf2;
      display: flex;
      align-items: center;
      border: 1px rgba($color: #1e516a, $alpha: 0.7) solid;
      font-size: 12px;
      div {
        padding: 1px 8px;
      }
    }
  }
  .datashow {
    margin-top: 10px;
    width: 100%;
    text-align: center;
    display: flex;
  }
}
</style>
